<?php	namespace Admin\Controller;
use Hdphp\Libs\Controller;
/**
 * 登陆管理控制器
 * @author 武斌   <wubin.mail@foxmail.com>
 * @Date 
 */
class LoginController extends Controller
{
	public function Config(){
		new \Hdphp\Tools\Code;
	}
	public function verifyCode(){
		$code =strtolower($_POST['u']);
		if($_SESSION['code'] == $code){
			echo 1;
		}else{
			echo 0;
		}
	}
	public function index()
	{
	if(IS_POST){
		$username = $_POST['username'];
		$password = $_POST['password'];
		if(strlen(trim($username))==0 ||strlen(trim($username))==0){
			$this->error("用户名或密码不能为空");exit;
		}
		$data =M()->query("select * from user where username='{$username}'");
		if(!$data){
			$this->error("用户名不存在");exit;
		}
		if(md5($password) != $data[0]['password']){
			$this->error("密码错误");exit;
		}
		$_SESSION['uid'] = $data[0]['uid'];
		$this->success("登录成功", 'index.php?m=Admin');exit;
	}
	$this->assign("title","登录页面");
	$this->assign("root",__ROOT__);
	$this->display();
	}
}
